package com.example.easybuy.service;

import com.example.easybuy.dao.OrderDao;
import com.example.easybuy.pojo.Order;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService{

    private Logger logger=Logger.getLogger(getClass());

    @Autowired
    private OrderDao orderDao;


    /*
    查询当前用户的订单列表
     */
    @Override
    public List<Order> getOrderList(int userId) {
        logger.debug("OrderServiceImpl-getOrderList()-userId:"+userId);
        List<Order> orderList=orderDao.getOrderList(userId);
        logger.debug("OrderServiceImpl-getOrderList()-orderList:"+orderList);
        return orderList;
    }

    /*
   删除订单信息
    */
    @Override
    public String deletOrderdatail(String id) {
        logger.debug("OrderServiceImpl-deletOrderdatail()-id:"+id);
        int deletId=Integer.valueOf(id);
        int deletRow=orderDao.deletOrderdatail(deletId);
        String success=null;
        if (deletRow>0){
            success="删除成功";
        }else {
            success="删除失败";
        }
        logger.debug("OrderServiceImpl-deletOrderdatail()-success:"+success);
        return success;
    }
}
